// 检查手机号码是否有效
function checkPhoneNum(number) {
    let reg = /^1(3|4|5|7|8)\d{9}$/;
    return reg.test(number) ? true : false;
}
function checkEmail(email) {
    let reg = /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/;
    return reg.test(email) ? true : false;
}

function showToast(msg) {
    wx.showToast({
        title: msg,
        icon: 'none',
        duration: 1000
    })
}
// 请求数据
function request(params) {
    // 设置header的contentType
    params.header = params.header || {};
    params.header['loginFlag'] = loginFlag();
    params.method = params.method || 'GET';
    wx.request(params)
}

function loginFlag() {
    console.log(wx.getStorageSync("loginFlag"))
    return wx.getStorageSync("loginFlag")
}

module.exports = {
    checkPhoneNum: checkPhoneNum,
    checkEmail: checkEmail,
    showToast: showToast,
    request: request
};